<template>
	<view>
		<lq-title title="设置"></lq-title>
		<cell-item label="账号安全" @click.native="toAccount"></cell-item>
		<!-- <cell-item label="内存清理" :content="cacheSize" @click.native="onClearCache"></cell-item> -->
		<cell-item label="用户协议" @click.native="onAgreement"></cell-item>
		<cell-item label="隐私政策" @click.native="onPrivacy"></cell-item>
		<cell-item label="版本号" :content="version" :arrow="false"></cell-item>
		<lq-button text="退出登录" @click.native="onLogout" style="margin: 100rpx 30rpx;"></lq-button>
	</view>
</template>

<script>
	import LoginUtil from '@/common/LoginUtil.js';
	import RouteUtil from '@/common/RouteUtil.js';
	export default {
		data() {
			return {
				pushChecked: false,
				version: '',
			}
		},
		onShow() {
			this.getPushChecked();
			this.getVersion();
		},
		methods: {
			toAccount() {
				RouteUtil.toAccount()
			},
			onAgreement() {
				RouteUtil.toAgreement()
			},
			onPrivacy() {
				RouteUtil.toPrivacy()
			},
			onPushChange(event) {
				uni.setStorageSync('push', event.detail.value);
			},
			async onLogout() {
				LoginUtil.logout()
			},
			getPushChecked() {
				let checked = uni.getStorageSync('push');
				if (checked) {
					this.pushChecked = checked;
				}
			},
			getVersion() {
				plus.runtime.getProperty(plus.runtime.appid, (info) => {
					this.version = 'v' + info.version;
				});
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>